<template>
  <div class='integral first-box'>
    <Filters @filterTime="search"></Filters>
    <Scroll :hasmore="hasmore" :pullup="pullup" setHeight="-33">
      <List :listData="listData"></List>
    </Scroll>
  </div>
</template>
<script>
import Filters from '../../../common/filters.vue'
import Scroll from '../../../common/scroller'
import List from './list'
export default {
  components: {Filters,Scroll,List},
  name: "",
  data() {
    return {
      hasmore:false,
      listData:[
        // {
        //  title:"完善个人信息",
        //  num:"10",
        //  type:1,
        //  time:"2018-12-25"
        // }
      ],
      pageInfo:{
        page:1,
        search:"",
        startTime:"",
        endTime:"",
      },
    };
  },
  methods: {
    search(params){
      this.pageInfo.page=1
      if(params.search){
        this.pageInfo.search=params.search
      }
      if(params.time&&params.time.length>0){
        this.pageInfo.startTime=params.time[0]
        this.pageInfo.endTime=params.time[1]
      }
      this.listData=[]
      this.getList()
    },

    // 下拉刷新方法回调
    pullup(func){
      if(this.hasmore){
        this.pageInfo.page++
         _g.orderList([this.getList,func])
         return
      }
      // func()
    },
    getList(){
      var params={
        currPageNo:this.pageInfo.page,
      }
      if(this.pageInfo.search){
        params.search=this.pageInfo.search
      }
      if(this.pageInfo.startTime&&this.pageInfo.endTime){
        params.startTime=this.pageInfo.startTime
        params.endTime=this.pageInfo.endTime
      }
       _g.apiPost("vipCenter/IntegralDetail.do",params).then(res=>{
         this.hasmore=res.data.hasNextPage
         var goal=[]
         res.data.list.forEach(ele => {
            goal.push({
              title:ele.businessType,
              num:ele.integral,
              type:ele.type,
              time:ele.operationTime||"暂无",
            })
         });
         this.$set(this,"listData",this.listData.concat(goal))
       })
    }
  },
  created() {
    this.getList()
  }
};
</script>
<style lang="scss" scoped>
.integral {

}
</style>